package com.nf.db.handlers.list;

import java.sql.ResultSet;
import java.sql.SQLException;

import static com.nf.db.handlers.RowProcessor.DEFAULT_ROWPROCESSOR;

/*
 * 让ResultSetHandler处理结果集，并将结果集转换为List<Bean>
 * */
public class BeanListHandler<T> extends AbstractListHandler<T> {
    private Class<?> clazz;

    public BeanListHandler(Class<?> clazz) {
        this.clazz = clazz;
    }

    @Override
    protected T handlerRow(ResultSet rs) throws SQLException {
        return (T) DEFAULT_ROWPROCESSOR.toBean(rs, clazz);
    }
}
